﻿using Architecture.API.Application.Command.MenuCommand;
using Architecture.Domain.Service.MenuServices;
using MediatR;

namespace Architecture.API.Application.CommandHandlers.MenuCommandHandler
{
    /// <summary>
    /// 菜单搜索计数命令处理器
    /// </summary>
    public class MenuSearchCountCommandHandlerL : IRequestHandler<MenuSearchCountCommand, int>
    {
        /// <summary>
        /// 菜单服务
        /// </summary>
        private readonly IMenuService _menuService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="menuService">菜单服务</param>
        public MenuSearchCountCommandHandlerL(IMenuService menuService)
        {
            _menuService = menuService;
        }

        /// <summary>
        /// 处理菜单搜索计数命令
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">取消标记</param>
        /// <returns>返回结果</returns>
        public async Task<int> Handle(MenuSearchCountCommand request, CancellationToken cancellationToken)
        {
            return await _menuService.GetMenuCount(request.MenuId);
        }
    }
}
